<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>

<body>
  <div id="app">
    <my-cpn></my-cpn>
    <cpn></cpn>
  </div>
  <div id="vm">
    <my-cpn></my-cpn>
    <cpn></cpn>
  </div>
  <script>
    // 1.创建组件构造器
    const cpnC = Vue.extend({ //传入对象
      template: `<div>
                  <h1>333</h1>
                  <h2>222</h2>
                  <h3>111</h3>
                </div>`      //``定义模板字符串
    })
    //2.注册组件
    //Vue.component('组件标签名（希望叫的名字）'，'组件构造器')
    Vue.component('my-cpn', cpnC)
    var vm = new Vue({
      el: '#vm',
      data: {
        name: 'Taec'
      },
      components: {
        cpn: cpnC
      }
    })
    var app = new Vue({
      el: '#app',
      data: { name: 'Taec' }
    })
  </script>
</body>

</html>